package com.ea.eadp.nexus.test.pageDefinition;
import com.ea.eadp.nexus.test.common.PageOperation;
import com.ea.eadp.nexus.test.common.TestUtil;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

/**
 * Created by ChuanYe on 9/8/2014.
 */
public class ContinueRegPage extends BasePage {
    private static final String successMessage = "Check Your Inbox";
    private static final String resultElement = "//*[@id='panel-twophase-request-confirmation']/div[1]/div/h1";
    protected String identifierId = "link_no_error";

    public ContinueRegPage(WebDriver driver) {
        super(driver, ContinueRegPage.class);
    }
    public void waitPageLoadCompleted() {
        WebDriverWait wait = new WebDriverWait(driver, 30, 1000);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(identifierId)));
    }
    public void setCaptcha(String captcha) {
        driver.switchTo().window(operationWindowHandle);
        PageOperation.SendKeyToElementAfterWait(driver, "recaptcha_response_field", captcha);
    }

    public boolean isVerifySuccess() {
        boolean success = driver.findElement(By.xpath(resultElement)).getText().contains(successMessage);
        return success;
    }
    public void nextStep() {
        driver.switchTo().window(operationWindowHandle);
        driver.findElement(By.xpath("//*[@id='panel-twophase-request']/div[2]/a/span/span")).click();
    }

}
